package com.pengcheng.taskapplication.mvp.presenter;
import android.app.Activity;
import android.content.Context;
import android.support.v4.app.Fragment;

import com.pengcheng.taskapplication.contants.ConstantValue;
import com.pengcheng.taskapplication.model.AccountTranModel;
import com.pengcheng.taskapplication.model.AccountVerify;
import com.pengcheng.taskapplication.model.BaseEntity;
import com.pengcheng.taskapplication.model.BaseListEntity;
import com.pengcheng.taskapplication.model.BindCardModel;
import com.pengcheng.taskapplication.model.CommitOrderModel;
import com.pengcheng.taskapplication.model.IcbcValidateModel;
import com.pengcheng.taskapplication.model.IcbcverifySms;
import com.pengcheng.taskapplication.model.IdcardAllOcrModel;
import com.pengcheng.taskapplication.model.PlateNoModel;
import com.pengcheng.taskapplication.model.UserVo;
import com.pengcheng.taskapplication.net.BaseSubscriber;
import com.pengcheng.taskapplication.net.IView;
import com.pengcheng.taskapplication.util.SPUtils;

import java.io.File;
import java.util.List;

import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;

/**
 * 任务
 */
public class UserPresenterV2 extends BasePresenterV2<IView> {
    public Context context;
    public UserPresenterV2(IView view) {
        super(view);
        if(view instanceof Activity){
            this.context=(Context) view;
        }else{
            this.context=((Fragment)view).getActivity();
        }

    }


    /**
     * 扫码入参接口
     * @param type
     */

    public void commitOrder(String token,String uid,String parkid,String laneno, String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);

        addSubscription(iHttpUrlV2.createOrder(token,uid,parkid,laneno), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 获取洗车类型列表接口
     * @param type
     */

    public void getwashoption(String token,String uid,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.getwashoption(token,uid), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 订单详情接口
     * @param type
     */

    public void getOrderDetail(String token,String uid,String tradno,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.getOrderDetail(token,uid,tradno), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 获取banner
     * @param type
     */

    public void getBanner(String type) {
        addSubscription(iHttpUrlV2.getBanner(), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 获取银行卡列表
     * @param type
     */
    public void getBankList(String token,String uid,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.getBankList(token,uid), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 签约
     * @param type
     */
    public void signCarNumber(String newtoken,String uid,String mvid,String signtype,String type) {
        newtoken = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);

        addSubscription(iHttpUrlV2.signCarNumber(newtoken,uid,mvid,signtype), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }




    /**
     * 洗车订单详情接口
     * @param type
     */

    public void getWashOrderDetail(String token,String uid,String tradno,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);

        addSubscription(iHttpUrlV2.getWashOrderDetail(token,uid,tradno), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 通知回调详情接口
     * @param type
     */

    public void notice(String token,String uid,String tradno,String type) {

        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.notice(token,uid,tradno), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 获取设备状态接口
     * @param type
     */

    public void getStatus(String token,String uid,String deviceid,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.getStatus(token,uid,deviceid), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 开启设备
     * @param type
     */

    public void startDevice(String token,String uid,String tradno,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.startDevice(token,uid,tradno), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }
    /**
     * 关闭设备
     * @param type
     */

    public void stopDevice(String token,String uid,String tradno,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.stopDevice(token,uid,tradno), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 通知回调详情接口
     * @param type
     */

    public void noticePark(String token,String uid,String tradno,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.noticePark(token,uid,tradno), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 拉取支付信息接口
     * @param type
     */

    public void wxpay(String token,String uid,String tradno,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.wxpay(token,uid,tradno), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 拉取支付信息接口
     * @param type
     */

    public void wxwashpay(String token,String uid,String tradno,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.wxwashpay(token,uid,tradno), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 新版登录信息接口
     * @param type
     */

    public void newLogin(String uid,String type) {

        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.newLogin(uid,0), new BaseSubscriber<BaseEntity>(context,false) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }


    public void checkToken(String token,String uid,String type){
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.checkToken(token,uid), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });

    }






    /**
     * 拉取停车订单列表信息接口
     * @param type
     */

    public void queryParkOrderList(String token,String uid,int page,int pagesize ,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);




        addSubscription(iHttpUrlV2.queryParkOrderList(token,uid,page,pagesize), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }


    /**
     * 获取通知列表
     * @param type
     */

    public void getNotcieList(String token,String uid,int page,int pagesize ,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.getNotice(token,uid,page,pagesize), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 获取通知列表
     * @param type
     */

    public void getBankInfo(String token,String uid,String accountnumber,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.getBankInfo(token,uid,accountnumber), new BaseSubscriber<BaseEntity>(context,false) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    public void bindingCard(String newtoken,String uid,String channel,String bankcardtype,String credentialnumber,
                            String bankid,String bankname,String bankaccountname,String bankaccountnumber,String bankphonenumber,String type){
        newtoken = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.bindingCard(newtoken,uid,channel,bankcardtype,credentialnumber,bankid,bankname,bankaccountname,bankaccountnumber,bankphonenumber), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    if(entity.resultCode.equals("7015")){
                        iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                    }else {
                        //iView.onFailed(entity.resultCode, entity.msg);
                        filterCustom(iView,entity);
                    }
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }


    /**
     * 获取通知列表
     * @param type
     */

    public void setPayPassword(String token,String uid,String paypwd,String vcode,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.setPayPassword(token,uid,paypwd,vcode), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    public void sendVcode(String token,String uid,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.sendVcode(token,uid), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }



    public void openAndClose(String token,String uid,String ispwd,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.openAndClose(token,uid,ispwd), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    public void getPayStatus(String token,String uid,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.getPayStatus(token,uid), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    public void getPaySort(String token,String uid,String channel,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.getPaySort(token,uid,channel), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    public void cpcnpay(String token,String uid,String tradno,String payway,String paypwd,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.cpcnpay(token,uid,tradno,payway,paypwd), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }




    public void setPaySort(String token,String uid,String payorder,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.setPayOrder(token,uid,payorder), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }




    public void smsverify(String token,String uid,String smscode,String bindingtxsn,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.smsverify(token,uid,smscode,bindingtxsn), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    public void unbind(String token,String uid,String bindingtxsn,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.unbind(token,uid,"2",bindingtxsn), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }



    public void updateLimitMoney(String token,String uid,double nopwdlimit,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.updateLimitMoney(token,uid,nopwdlimit), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 获取车牌列表
     * @param type
     */

    public void getCarSignList(String token,String uid,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.getSignCarList(token,uid), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }


    /**
     * 拉取洗车订单列表信息接口
     * @param type
     */

    public void queryWashOrderList(String token,String uid,int page,int pagesize ,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.queryWashOrderList(token,uid,page,pagesize), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 拉取我的车牌
     * @param type
     */

    public void queryWashOList(String token,String uid,int page,int pagesize ,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.queryWashOrderList(token,uid,page,pagesize), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                    //iView.onFailed(entity.resultCode, entity.msg);
                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 生成洗车订单接口
     * @param type
     */

    public void createWashOrder(String token,String uid,String washid,String deviceid,String washtype,String type) {
        token = SPUtils.getString(context, ConstantValue.SpType.newtoken);
        uid = SPUtils.getString(context, ConstantValue.SpType.userid);
        addSubscription(iHttpUrlV2.createWashOrder(token,uid,washid,deviceid,washtype), new BaseSubscriber<BaseEntity>(context) {
            @Override
            public void onNext(BaseEntity entity) {
                if (entity.result) {
                    iView.onSuccess(entity.resultCode, entity.msg, entity.data, type);
                } else {
                   // iView.onFailed(entity.resultCode, entity.msg);

                    filterCustom(iView,entity);
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }



    public void filterCustom(IView iView,BaseEntity baseEntity){
        if(baseEntity.resultCode.equals("904")){

        }else{
            iView.onFailed(baseEntity.resultCode,baseEntity.msg);
        }
    }



}
